<?php
include_once( 'function.php' );

if(v('ps') == PS )
{
	if( !isset($GLOBALS['sess']) )
	{
		session_start();
		$GLOBALS['sess'] = true;
	}
		
	$_SESSION['ps'] = PS;	
	
}

$tag = v('tag');
if( $tag == '' ) $tag = 'index';

$tag_file = 'pages/' . md5( $tag ) . '.data.txt';
$default_tag_file = 'pages/default.data.txt';

if( file_exists( $tag_file ) )
	$content = file_get_contents( $tag_file );
else
	$content = @file_get_contents( $default_tag_file );

$content = preg_replace_callback ( '/\[\[(.+?)\]\]/is' , 
		create_function(     
			'$matches',
            'return "<a href=index.php?tag=" . urlencode($matches[1]) . ">" . $matches[1] . "</a>";'
        )
		, $content );

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title><?php echo $tag; ?> - Riki</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="robots" content="noindex, nofollow">
		<link href="style.css" rel="stylesheet" type="text/css" />
	</head>
	<body ondblclick="location='modify.php?tag=<?php echo urlencode($tag); ?>'">
		<h1><?php echo $tag; ?> - Riki - [<a href="index.php">Home</a>]</h1>
		<div style="border-bottom:1px solid #ccc;bottom-top:10px"></div>
		<div style="padding:20px;margin:20px;border:1px solid #ccc;_height:400px;min-height:400px" >
			<?php echo $content; ?>
		</div>
		<div style="border-top:1px solid #ccc;margin-top:10px">  </div>
	
	</body>
</html>